package com.daylightrobbery.server.packet.game;

import com.daylightrobbery.server.entity.PlayerInfo;
import com.daylightrobbery.server.packet.gameobjects.CommonHouse;
import com.daylightrobbery.server.packet.gameobjects.HouseDescription;
import com.daylightrobbery.server.packet.type.DataPacket;
import com.daylightrobbery.server.packet.type.RoomDataPacket;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * 游戏数据同步包
 */
@Component
public class GamePrepareDataPacket implements RoomDataPacket {

    private int type = 30002;

    private int roomId;
    private String currentTurnPlayerUid;
    private int pathCounts;
    private int rewardTickets;
    private HashMap<String, PlayerInitAssets> playerData = new HashMap<>();
    private HashMap<String, Integer> characterInfo = new HashMap<>();
    private HashMap<String, Integer> playerPosition = new HashMap<>();
    private HashMap<String, PlayerInfo> playerInfo = new HashMap<>();
    private HashMap<Integer, HouseDescription> houseInfo = new HashMap<>();

    public int getRewardTickets() {
        return rewardTickets;
    }

    public GamePrepareDataPacket setRewardTickets(int rewardTickets) {
        this.rewardTickets = rewardTickets;
        return this;
    }

    public HashMap<String, PlayerInfo> getPlayerInfo() {
        return playerInfo;
    }

    public GamePrepareDataPacket setPlayerInfo(HashMap<String, PlayerInfo> playerInfo) {
        this.playerInfo = playerInfo;
        return this;
    }

    public GamePrepareDataPacket addPlayerInfo(String uid, PlayerInfo info){
        this.playerInfo.put(uid, info);
        return this;
    }

    public HashMap<String, Integer> getPlayerPosition() {
        return playerPosition;
    }

    public GamePrepareDataPacket setPlayerPosition(HashMap<String, Integer> playerPosition) {
        this.playerPosition = playerPosition;
        return this;
    }

    public GamePrepareDataPacket addPlayerPosition(String uid, Integer index){
        this.playerPosition.put(uid, index);
        return this;
    }

    public HashMap<String, Integer> getCharacterInfo() {
        return characterInfo;
    }

    public GamePrepareDataPacket setCharacterInfo(HashMap<String, Integer> characterInfo) {
        this.characterInfo = characterInfo;
        return this;
    }


    public int getPathCounts() {
        return pathCounts;
    }

    public GamePrepareDataPacket setPathCounts(int pathCounts) {
        this.pathCounts = pathCounts;
        return this;
    }

    public void addCharacterInfo(String uid, Integer index){
        characterInfo.put(uid, index);
    }

    public void addPlayerData(String uid, PlayerInitAssets assets){
        this.playerData.put(uid, assets);
    }

    public GamePrepareDataPacket setRoomId(Integer roomId) {
        this.roomId = roomId;
        return this;
    }

    public String getCurrentTurnPlayerUid() {
        return currentTurnPlayerUid;
    }

    public GamePrepareDataPacket setCurrentTurnPlayerUid(String currentTurnPlayerUid) {
        this.currentTurnPlayerUid = currentTurnPlayerUid;
        return this;
    }

    public HashMap<String, PlayerInitAssets> getPlayerData() {
        return playerData;
    }

    public GamePrepareDataPacket setPlayerData(HashMap<String, PlayerInitAssets> playerData) {
        this.playerData = playerData;
        return this;
    }

    public HashMap<Integer, HouseDescription> getHouseInfo() {
        return houseInfo;
    }

    public GamePrepareDataPacket setHouseInfo(HashMap<Integer, HouseDescription> houseInfo) {
        this.houseInfo = houseInfo;
        return this;
    }

    public GamePrepareDataPacket addHouseInfo(int pathIndex, HouseDescription house){
        this.houseInfo.put(pathIndex, house);
        return this;
    }

    @Override
    public DataPacket process() {
        return null;
    }

    @Override
    public int getType() {
        return type;
    }

    @Override
    public int getRoomId() {
        return roomId;
    }
}
